package net.hmr_radio.hmrbot.controller.json;

import net.hmr_radio.hmrbot.controller.BaseLoggedInController;
import net.hmr_radio.hmrbot.dto.BotDto;
import net.hmr_radio.hmrbot.service.BotService;
import net.hmr_radio.hmrbot.util.JsonUtil;

import org.slim3.controller.Navigation;

public class BotController extends BaseLoggedInController {

    private BotService botService = new BotService();

    @Override
    public Navigation doRun() throws Exception {
        if (getTwitter() == null) {
            return JsonUtil.writeJson(response, new Object());
        }

        BotDto botDto = new BotDto(botService.get(asKey("key")), getTwitter());
        return JsonUtil.writeJson(response, botDto);
    }
}
